<template>
  <div class="page-container">
    <!-- 顶部导航 -->
    <header class="header">
      <div class="header-container">
        <div class="back-btn" @click="handleBack">
          <i class="fas fa-arrow-left"></i>
        </div>
        <h1 class="header-title">危机咨询记录</h1>

        <div class="header-left">
          <div class="header-icon">
            <i class="fas fa-headset"></i>
          </div>
        </div>
      </div>
    </header>

    <main class="main-content">
      <!-- 主记录卡片 -->
      <div class="card urgent animate-fade-in">
        <div class="card-header">
          <div class="patient-info">
            <div class="patient-icon">
              <i class="fas fa-user-injured"></i>
            </div>
            <h2 class="patient-name">张明轩 - 危机干预记录</h2>
          </div>
          <span class="status-badge status-urgent">紧急干预</span>
        </div>

        <!-- 咨询师信息 -->
        <div class="info-section">
          <div class="section-title">
            <i class="fas fa-user-md"></i>
            <span>咨询师</span>
          </div>
          <div class="info-content">
            <div class="consultant-info">
              <div class="consultant-avatar">李</div>
              <div class="consultant-details">
                <h3 class="consultant-name">李明华 博士</h3>
                <p class="consultant-title">资深危机干预专家 | 注册心理师</p>
              </div>
            </div>
          </div>
        </div>

        <!-- 咨询时间 -->
        <div class="info-section">
          <div class="section-title">
            <i class="far fa-calendar-alt"></i>
            <span>咨询时间</span>
          </div>
          <div class="info-content">
            <div class="time-details">
              <div class="time-item">
                <p class="time-label">日期与时间</p>
                <p class="time-value">2023-08-15 14:30</p>
              </div>
              <div class="time-item">
                <p class="time-label">咨询时长</p>
                <p class="time-value">2.5 小时</p>
              </div>
            </div>
          </div>
        </div>

        <!-- 咨询要点 -->
        <div class="info-section">
          <div class="section-title">
            <i class="fas fa-clipboard-list"></i>
            <span>咨询要点</span>
          </div>
          <div class="info-content notes-content">
            <p>
              来访者因近期失业和婚姻危机表现出严重的自杀意念。自述连续两周失眠，食欲不振，对生活失去信心。在咨询过程中表达"活着没意思"等消极言论。对支持系统评价较低，表示家人朋友"都不理解我"。
            </p>
            <div class="critical-info">
              <i class="fas fa-exclamation-circle"></i>
              <span>评估自杀风险等级：高危（有具体计划，曾尝试获取药物）</span>
            </div>
          </div>
        </div>

        <!-- 观察与建议 -->
        <div class="info-section">
          <div class="section-title">
            <i class="fas fa-binoculars"></i>
            <span>观察与建议</span>
          </div>
          <div class="info-content observation-content">
            <p class="observation-item">
              1. 观察到明显的情绪低落、精神运动性迟滞及绝望感增加
            </p>
            <p class="observation-item">
              2. 存在认知扭曲（全或无思维）和负性归因模式
            </p>
            <p class="observation-item">3. 社会支持系统薄弱，缺乏应对资源</p>

            <p class="sub-title">紧急干预措施：</p>
            <ul class="measures-list">
              <li>已签署不自杀协议</li>
              <li>联络家属提供24小时监护</li>
              <li>转介精神科医生进行药物评估</li>
              <li>预约48小时内跟进咨询</li>
            </ul>

            <p class="sub-title">长期建议：</p>
            <ul class="measures-list">
              <li>认知行为治疗解决负性思维模式</li>
              <li>社会技能训练重建支持系统</li>
              <li>职业咨询与再就业规划</li>
            </ul>
          </div>
        </div>

        <!-- 操作按钮 -->
        <div class="action-buttons">
          <button class="btn-primary" @click="updateRecord">
            <i class="fas fa-file-medical"></i>
            <span>更新记录</span>
          </button>
          <button class="btn-secondary">
            <i class="fas fa-print"></i>
            <span>打印报告</span>
          </button>
        </div>
      </div>

      <!-- 历史记录 -->
      <h3 class="history-title">
        <i class="fas fa-history"></i>
        <span>历史咨询记录</span>
      </h3>

      <div class="history-list">
        <!-- 记录1 -->
        <div
          class="history-card animate-fade-in"
          :style="{ 'animation-delay': '0.1s' }"
          @click="loadRecord(1)"
        >
          <div class="history-header">
            <h4 class="history-name">第三次咨询跟进</h4>
            <span class="history-date">2023-07-28 10:15</span>
          </div>
          <div class="history-details">
            <div class="history-detail">
              <i class="fas fa-user-md"></i>
              <span>李明华</span>
            </div>
            <div class="history-detail">
              <i class="far fa-clock"></i>
              <span>1.5小时</span>
            </div>
          </div>
        </div>

        <!-- 记录2 -->
        <div
          class="history-card animate-fade-in"
          :style="{ 'animation-delay': '0.2s' }"
          @click="loadRecord(2)"
        >
          <div class="history-header">
            <h4 class="history-name">第二次咨询</h4>
            <span class="history-date">2023-07-14 15:30</span>
          </div>
          <div class="history-details">
            <div class="history-detail">
              <i class="fas fa-user-md"></i>
              <span>王思雨</span>
            </div>
            <div class="history-detail">
              <i class="far fa-clock"></i>
              <span>2小时</span>
            </div>
          </div>
        </div>

        <!-- 记录3 -->
        <div
          class="history-card animate-fade-in"
          :style="{ 'animation-delay': '0.3s' }"
          @click="loadRecord(3)"
        >
          <div class="history-header">
            <h4 class="history-name">首次评估咨询</h4>
            <span class="history-date">2023-06-30 09:00</span>
          </div>
          <div class="history-details">
            <div class="history-detail">
              <i class="fas fa-user-md"></i>
              <span>陈志强</span>
            </div>
            <div class="history-detail">
              <i class="far fa-clock"></i>
              <span>1小时</span>
            </div>
          </div>
        </div>
      </div>
    </main>

    <!-- 底部导航 -->
    <!-- <nav class="bottom-nav">
      <div class="nav-container">
        <div class="nav-items">
          <div
            class="nav-item"
            :class="{ active: activeNav === 'home' }"
            @click="setActiveNav('home')"
          >
            <i class="fas fa-home"></i>
            <span class="nav-label">首页</span>
          </div>
          <div
            class="nav-item active"
            :class="{ active: activeNav === 'records' }"
            @click="setActiveNav('records')"
          >
            <i class="fas fa-file-medical"></i>
            <span class="nav-label">记录</span>
          </div>
          <div
            class="nav-item"
            :class="{ active: activeNav === 'schedule' }"
            @click="setActiveNav('schedule')"
          >
            <i class="fas fa-calendar-check"></i>
            <span class="nav-label">日程</span>
          </div>
          <div
            class="nav-item"
            :class="{ active: activeNav === 'analytics' }"
            @click="setActiveNav('analytics')"
          >
            <i class="fas fa-chart-line"></i>
            <span class="nav-label">分析</span>
          </div>
          <div
            class="nav-item"
            :class="{ active: activeNav === 'profile' }"
            @click="setActiveNav('profile')"
          >
            <i class="fas fa-user"></i>
            <span class="nav-label">我的</span>
          </div>
        </div>
      </div>
    </nav> -->
  </div>
</template>

<script>
export default {
  name: "CrisisConsultation",
  data() {
    return {
      activeNav: "records",
    };
  },
  methods: {
    setActiveNav(nav) {
      this.activeNav = nav;
    },
    updateRecord() {
      const button = event.currentTarget;
      const originalHTML = button.innerHTML;
      button.innerHTML = '<i class="fas fa-spinner"></i> 保存中...';
      button.classList.add("loading");

      setTimeout(() => {
        button.innerHTML = originalHTML;
        button.classList.remove("loading");

        // 显示保存成功的消息
        this.showToast("记录更新成功！", "success");
      }, 1500);
    },
    loadRecord(index) {
      const titles = ["第三次咨询跟进", "第二次咨询", "首次评估咨询"];

      this.showToast(`正在加载: ${titles[index - 1]}`, "loading");

      setTimeout(() => {
        this.showToast(`已加载: ${titles[index - 1]}`, "success");
      }, 1000);
    },
    showToast(message, type) {
      // 创建toast元素
      const toast = document.createElement("div");
      toast.className = `toast toast-${type}`;

      let icon = "";
      if (type === "success") {
        icon = '<i class="fas fa-check-circle"></i>';
      } else if (type === "loading") {
        icon = '<i class="fas fa-spinner fa-spin"></i>';
      }

      toast.innerHTML = `${icon} ${message}`;
      document.body.appendChild(toast);

      // 显示toast
      setTimeout(() => {
        toast.classList.add("show");
      }, 10);

      // 2秒后移除toast
      setTimeout(() => {
        toast.classList.remove("show");
        setTimeout(() => {
          document.body.removeChild(toast);
        }, 300);
      }, 2000);
    },
  },
};
</script>

<style scoped>
/* 基础样式 */
.page-container {
  font-family: "Noto Sans SC", sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
  padding-bottom: 80px;
  position: relative;
  min-height: 100vh;
}

/* 顶部导航 */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background-color: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
}

.header-icon i {
  font-size: 20px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
}

.header-right {
  display: flex;
  gap: 12px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
  border: none;
  cursor: pointer;
}

/* 主内容区域 */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  margin-top: 24px;
}

/* 卡片样式 */
.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  padding: 24px;
  margin-bottom: 24px;
}

.card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.urgent {
  background-color: #fff5f5;
  border-left: 4px solid #ef4444;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f3f4f6;
}

.patient-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.patient-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
}

.patient-icon i {
  font-size: 20px;
}

.patient-name {
  font-size: 18px;
  font-weight: 700;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-urgent {
  background-color: #fee2e2;
  color: #dc2626;
}

/* 信息部分 */
.info-section {
  margin-bottom: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
}

.section-title i {
  margin-right: 8px;
  color: #4f46e5;
}

.info-content {
  background-color: #f9fafb;
  border-radius: 12px;
  padding: 16px;
}

.consultant-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.consultant-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.consultant-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.consultant-title {
  font-size: 14px;
  color: #6b7280;
}

.time-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.time-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
}

.time-value {
  font-weight: 700;
  color: #4f46e5;
}

.notes-content {
  min-height: 120px;
}

.critical-info {
  background-color: #fef2f2;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  margin-top: 12px;
}

.critical-info i {
  color: #ef4444;
  margin-right: 8px;
  margin-top: 2px;
}

.critical-info span {
  color: #dc2626;
  font-weight: 500;
}

.observation-content {
  background-color: #fdf2f8;
  min-height: 150px;
}

.observation-item {
  font-weight: 500;
  margin-bottom: 8px;
}

.sub-title {
  font-weight: 700;
  margin-bottom: 4px;
  margin-top: 16px;
}

.measures-list {
  list-style-type: disc;
  padding-left: 20px;
  margin-bottom: 12px;
  font-size: 14px;
}

.measures-list li {
  margin-bottom: 4px;
}

/* 操作按钮 */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary,
.btn-secondary {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.3s;
}

.btn-primary {
  background: linear-gradient(to right, #6366f1, #8b5cf6);
  color: white;
}

.btn-secondary {
  background-color: white;
  border: 1px solid #e5e7eb;
  color: #374151;
}

.btn-primary.loading {
  opacity: 0.75;
}

/* 历史记录 */
.history-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.history-title i {
  color: #4f46e5;
  margin-right: 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.history-card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-name {
  font-weight: 700;
}

.history-date {
  font-size: 14px;
  color: #6b7280;
}

.history-details {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: #6b7280;
}

.history-detail {
  display: flex;
  align-items: center;
}

.history-detail i {
  color: #4f46e5;
  margin-right: 4px;
}

/* 底部导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
}

.nav-items {
  display: flex;
  justify-content: space-around;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #6b7280;
  cursor: pointer;
}

.nav-item.active {
  color: #6366f1;
  position: relative;
}

.nav-item.active::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: #6366f1;
  border-radius: 3px;
}

.nav-item i {
  font-size: 20px;
}

.nav-label {
  font-size: 12px;
  margin-top: 4px;
}

/* 页脚 */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding-bottom: 4px;
  z-index: -1;
  line-height: 1.4;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

/* Toast消息 */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background-color: #10b981;
  color: white;
  padding: 8px 16px;
  border-radius: 9999px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast i {
  margin-right: 8px;
}

.toast-loading {
  background-color: #6366f1;
}

.toast-success {
  background-color: #10b981;
}
.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b67ff;
  cursor: pointer;
}
</style>
